package game.classes.gameField;

import game.classes.interfaces.Block;
import game.classes.interfaces.Usable;
import game.enums.BlockID;
import game.enums.MaterialID;

public class gameUsable extends gameBlock implements Usable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// gameBlock
	int posX;
	int posY;
	BlockID myBlockID;
	MaterialID myMaterialID;
	Block[][] listOfBlocks;
	// this
	private boolean activated = false;

	public gameUsable(int x,int y,BlockID bID,Block[][] list)
	{
		super(x, y, bID, list);
		posX = x;
		posY = y;
		myBlockID = bID;
		listOfBlocks = list;
	}
	
	public gameUsable(int x,int y,BlockID bID,MaterialID mID,Block[][] list)
	{
		super(x, y, bID, mID, list);
		posX = x;
		posY = y;
		myMaterialID = mID;
		myBlockID = bID;
		listOfBlocks = list;
	}

	@Override
	public int getX() {
		return x;
	}

	@Override
	public int getY() {
		return y;
	}

	@Override
	public MaterialID getMaterial() {
		return myMaterialID;
	}

	@Override
	public BlockID getBlockID() {
		return myBlockID;
	}

	@Override
	public Block getBlockLeft() {
		if (posX > 0) {
			return listOfBlocks[posX-1][posY];
		}
		return null;
	}

	@Override
	public Block getBlockAbove() {
		if (posY > 0) {
			return listOfBlocks[posX][posY-1];
		}
		return null;
	}

	@Override
	public Block getBlockRight() {
		if (posX < listOfBlocks.length) {
			return listOfBlocks[posX+1][posY];
		}
		return null;
	}

	@Override
	public Block getBlockBelow() {
		if (posY < listOfBlocks[0].length) {
			return listOfBlocks[posX][posY+1];
		}
		return null;
	}

	@Override
	public void activate() {
		activated = !activated;
	}

	@Override
	public boolean isActive() {
		return activated;
	}

}
